<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./promise.js"></script>
</head>
<body>
    <h1>自定义Promise--异步修改状态then方法返回值</h1>
    <script>
        // 使用自定义的Promise
        const p = new Promise((resolve, reject)=>{
            setTimeout(()=>{
                try{
                    //resolve("成功了");
                    throw "出错了";
                }catch(e){
                    reject(e);
                }
            },0)
            
        });

        console.log(p);
        // 使用promise
        const p2 = p.then(v => {
            console.log("ok01",v);
            //return 100;
            //throw "Error";
             return new Promise((resolve, reject)=>{
                     resolve("mm");
                     //throw "出错了";
                 });
        },r => {
            console.log("err01",r);
            //throw "error";
        })

        console.log(p2);

        

    </script>
</body>
</html>